import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:keyboard_avoider/keyboard_avoider.dart';

class Home extends StatefulWidget {
  Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}


class _HomeState extends State<Home> {
  var avatorImageHeight = null;
  bool isShowPutDown = false;
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Expanded(
          flex: 1,
          child: Container(
            width: 800,
            decoration: BoxDecoration(
                gradient: LinearGradient(
                    //渐变位置
                    begin: Alignment.topCenter, //右上
                    end: Alignment.bottomCenter, //左下
                    stops: [
                  0.0,
                  1.0
                ], //[渐变起始点, 渐变结束点]
                    //渐变颜色[始点颜色, 结束颜色]
                    colors: [
                  Color.fromRGBO(243, 110, 71, 1),
                  Color.fromRGBO(255, 255, 146, 1)
                ])),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                SizedBox(height: 50),
                Text(
                  '快捷通话',
                  style: TextStyle(
                      fontSize: 19,
                      color: Colors.white,
                      fontWeight: FontWeight.bold),
                ),
                SizedBox(height: 15),
                Container(
                    height:this.avatorImageHeight == null?205:0,
                    width: 205,
                    child: Stack(children: [
                      Align(
                        alignment: Alignment.center,
                        child: ClipOval(
                          child: Container(
                            height: 205,
                            width: 205,
                            decoration: BoxDecoration(
                                color: Color.fromRGBO(255, 255, 255, 0.5)),
                          ),
                        ),
                      ),
                      Align(
                        alignment: Alignment.center,
                        child: ClipOval(
                          child: Container(
                            height: 150,
                            width: 150,
                            decoration: BoxDecoration(
                                color: Color.fromRGBO(255, 255, 255, 0.5)),
                          ),
                        ),
                      ),
                      Align(
                        alignment: Alignment.center,
                        child: ClipOval(
                          child: Image.network(
                            "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=820522811,1360565466&fm=11&gp=0.jpg",
                            height: 110,
                            width: 110,
                          ),
                        ),
                      ),
                    ])),
                Container(
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
                    margin: EdgeInsets.fromLTRB(0, 15, 0, 10),
                    child: Text(
                      "全部消息",
                      textAlign: TextAlign.left,
                      style: TextStyle(
                          fontSize: 14,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                  )),
                Expanded(
                    child: Container(
                        height: 200,
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.only(
                                topLeft: Radius.circular(25),
                                topRight: Radius.circular(25))),
                        child: Listener(
                          child: ListView(
                            padding: EdgeInsets.fromLTRB(10, 0, 10, 10),
                            children: [
                              Container(
                                height: this.isShowPutDown == false?0:20,
                                width: 20,
                                
                                child:IconButton(
                                  icon: Icon(Icons.keyboard_arrow_down, color: Colors.grey,),
                                  alignment: Alignment.center,
                                  padding: EdgeInsets.all(0),
                                  onPressed: () {
                                    print(1);
                                    setState(() {
                                      this.isShowPutDown = false;
                                      this.avatorImageHeight = null;
                                    });
                                    
                                  },
                                )
                              ),
                              Container(
                                  height: 40,
                                  alignment: Alignment.center,
                                  margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
                                  child: TextField(
                                    textAlign: TextAlign.justify,
                                    decoration: InputDecoration(
                                        hintText: "搜索",
                                        hintStyle: TextStyle(
                                          color: Colors.grey,
                                        ),
                                        contentPadding:
                                            EdgeInsets.fromLTRB(0, 5, 0, 0),
                                        prefixIcon: Icon(Icons.search),
                                        border: OutlineInputBorder(
                                            borderRadius:
                                                BorderRadius.circular(150)),
                                        labelText: '搜索'),
                                    onSubmitted: (value) {
                                      print(value);
                                    },
                                    onTap: () {},
                                  )),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                              Card(
                                shadowColor: Color.fromRGBO(0, 0, 0, 0.3),
                                child: ListTile(
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=667278971,130890256&fm=11&gp=0.jpg",
                                        scale: 42),
                                  ),
                                  title: Text('小程'),
                                  subtitle: Text('今天有空吗？'),
                                  trailing: Text('10.19'),
                                ),
                              ),
                            ],
                          ),
                          onPointerMove: (PointerMoveEvent event) {
                            setState(() {
                              this.avatorImageHeight = true;
                              this.isShowPutDown = true;
                            });
                          },
                        )))
              ],
            ),
          )
      ),
    );
  }
}
